<template>
  <div class="app-container">
    <div style="font-size: 24px; margin: 10px 10px 0px 10px; font-weight: 500">
      未启用
    </div>
    <div class="app-div">
      <el-card class="app-hover" v-for="item in notEnabledList">
        <div style="display: flex; margin-bottom: 8px">
          <div style="font-size: 17px">{{ item.name }}</div>
          <div
            v-if="!item.openTime"
            style="
              border-radius: 12px;
              margin-left: 10px;
              height: 24px;
              line-height: 20px;
              font-size: 12px;
              background-color: rgb(221, 88, 88);
              padding: 2px 10px;
              color: #fff;
            "
          >
            NEW
          </div>
        </div>
        <div style="display: flex">
          <div style="font-size: 14px; color: #9e9e9e; padding-right: 5px">
            {{ item.funcDesc }}
          </div>
          <el-button
            style="height: 30px; margin-top: 5px; font-size: 14px"
            size="mini"
            @click="getReportUpdate(item)"
            >启用</el-button
          >
        </div>
      </el-card>
    </div>
    <div style="font-size: 24px; margin: 40px 10px 0px 10px; font-weight: 500">
      已启用
    </div>
    <div class="app-div">
      <el-card class="app-hover" v-for="item in enabledList">
        <div style="display: flex; margin-bottom: 8px">
          <div style="font-size: 17px">{{ item.name }}</div>
          <div
            v-if="!item.openTime"
            style="
              border-radius: 12px;
              margin-left: 10px;
              height: 24px;
              line-height: 20px;
              font-size: 12px;
              background-color: rgb(221, 88, 88);
              padding: 2px 10px;
              color: #fff;
            "
          >
            NEW
          </div>
        </div>
        <div style="display: flex">
          <div style="font-size: 14px; color: #9e9e9e; padding-right: 5px">
            {{ item.funcDesc }}
          </div>
          <el-button
            style="height: 30px; margin-top: 5px; font-size: 14px"
            size="mini"
            @click="getReportUpdate(item)"
            >停用</el-button
          >
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
import { reportUpdate, reportList } from "@/api/system/configuration";
export default {
  name: "functional_Configuration",
  data() {
    return {
      notEnabledList: [],
      enabledList: [],
    };
  },
  created() {
    this.getReportList();
  },
  methods: {
    // 查询报表功能配置列表
    getReportList() {
      this.notEnabledList = [];
      this.enabledList = [];
      reportList().then((res) => {
        res.data.forEach((item) => {
          if (item.status !== 1) {
            this.notEnabledList.unshift(item);
          } else {
            this.enabledList.unshift(item);
          }
        });
      });
    },
    // 修改查询报表功能配置列表
    getReportUpdate(item) {
      let status;
      if (item.status !== 1) {
        status = 1;
      } else {
        status = 0;
      }
      reportUpdate({ id: item.id, status }).then((res) => {
        if (res && res.code === 200) {
          this.getReportList();
          this.$message.success(res.msg);
        } else {
          this.$message.error(res.msg);
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.app-div {
  display: flex;
  flex-wrap: wrap;
}
.app-hover {
  box-shadow: 3px 3px 4px rgba(185, 185, 185, 0.5);
  margin: 10px;
  width: 310px;
  height: 130px;
}
.app-hover:hover {
  box-shadow: 4px 4px 8px rgba(185, 185, 185, 0.5);
  transform: scale(1.04);
}
</style>
